package com.ourteam.education.api;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import com.ourteam.education.dao.ClassroomDAOQueryBean;
import com.ourteam.education.domain.ClassroomBean;
import com.ourteam.frame.web.AbstractSearchModel;

public class ClassroomSearchBean extends AbstractSearchModel<ClassroomDAOQueryBean> {

	private String classroomName;

	private Long campusId;

	private String[] status;

	public String getClassroomName() {
		return classroomName;
	}

	public void setClassroomName(String classroomName) {
		this.classroomName = classroomName;
	}

	public Long getCampusId() {
		return campusId;
	}

	public void setCampusId(Long campusId) {
		this.campusId = campusId;
	}

	public String[] getStatus() {
		return status;
	}

	public void setStatus(String[] status) {
		this.status = status;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ClassroomBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ClassroomDAOQueryBean queryBean) throws Exception {

		ClassroomDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNoneBlank(classroomName)) {

			criteria.andClassroomNameLike(classroomName);

		}

		if (this.campusId != null && this.campusId.intValue() != 0) {
			criteria.andCampusIdEqualTo(campusId);
		}

		if (ArrayUtils.isNotEmpty(status)) {
			criteria.andStatusIn(status);
		}
	}

}
